package cn.com.checne.util;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.ui.ModelMap;

import cn.com.checne.constants.Constants;

public class LanguageUtils {

	public static int getLanguage(String lg){
		if(StringUtils.isBlank(lg)){
			return Constants.language_CN_;
		}
		if(lg.equalsIgnoreCase(Constants.LANGUAGE_CN)){
			return Constants.language_CN_ ;
		}
		if(lg.equalsIgnoreCase(Constants.LANGUAGE_EN)){
			return Constants.LANGUAGE_EN_ ;
		}
		return Constants.language_CN_;
	}
	
	public static int getLanguage(HttpServletRequest request,String parameter){
		String lg = WebUtils.getRequestParameterAsString(request, parameter);
		if(StringUtils.isBlank(lg)){
			return Constants.language_CN_;
		}
		if(lg.equalsIgnoreCase(Constants.LANGUAGE_CN)){
			return Constants.language_CN_ ;
		}
		if(lg.equalsIgnoreCase(Constants.LANGUAGE_EN)){
			return Constants.LANGUAGE_EN_ ;
		}
		return Constants.language_CN_;
	}
	
	public static ModelMap getModelMap(String lg){
		ModelMap map = new ModelMap();
		String baseTitle = lg.equals("cn") ? "华电新能源技术开发公司" : "CHINA HUADIAN NEW ENERY DEV CO.,LTD"  ;
		map.put("baseTitle", baseTitle);
		map.put("lg",lg);
		return map ;
	}
	
}
